home *** CD-ROM | disk | FTP | other *** search
/ Aminet 28 / Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso / Aminet / dev / misc / gms_dev.lha / GMSDev / Includes / dpkernel / dpkernel.i < prev    next >
Encoding:
Text File  |  1998-10-11  |  11.9 KB  |  395 lines

  1.     IFND DPKERNEL_I
  2. DPKERNEL_I  SET  1
  3.  
  4. **
  5. **  $VER: dpkernel.i V2.1
  6. **
  7. **  General include file for programs using the DPKernel.
  8. **
  9. **  (C) Copyright 1996-1998 DreamWorld Productions.
  10. **      All Rights Reserved.
  11. **
  12. **
  13.  
  14.     IFND    LIBRARIES_DPKERNEL_LIB_I
  15.     include    'modules/dpkernel_lib.i'
  16.     include    'modules/screens.i'
  17.     include    'modules/blitter.i'
  18.     include    'modules/sound.i'
  19.     ENDC
  20.  
  21.     IFND    SYSTEM_TYPES_I
  22.     include 'system/types.i'
  23.     ENDC
  24.  
  25.     IFND    SYSTEM_REGISTER_I
  26.     include    'system/register.i'
  27.     ENDC
  28.  
  29. ****************************************************************************
  30.  
  31. DPKVersion  =  2             ;Version for these includes.
  32. DPKRevision =  1             ;Revision for these includes.
  33.  
  34. SKIPENTRY   =  0             ;Used to skip to the next entry.
  35. ENDLIST     =  -1            ;Used to terminate a list.
  36. LISTEND     =  -1            ;Synonym for ENDLIST.
  37. TAGEND      =  0             ;Used to terminate a tag list.
  38. DEFAULT     =  0
  39.  
  40. TBYTE       =  0             ;Flags used for constructing tag lists.
  41. TLONG       =  (1<<31)
  42. TWORD       =  (1<<30)
  43. TAPTR       =  (1<<29)|TLONG
  44. TSTEPIN     =  (1<<28)
  45. TSTEPOUT    =  (1<<27)
  46. TTRIGGER    =  (1<<26)
  47.  
  48.   IFND    TAG_IGNORE
  49. TAG_IGNORE  =  1
  50. TAG_MORE    =  2
  51. TAG_SKIP    =  3
  52.   ENDC
  53.  
  54. GET_NOTRACK = $00010000             ;Disables tracking on an object.
  55. GET_PUBLIC  = $00020000             ;If the object is to be passed to other tasks/processes.
  56. GET_SHARE   = $00040000|GET_PUBLIC  ;If the object is to be openly shared with foreign tasks.
  57.  
  58. ****************************************************************************
  59. * Function synonyms.
  60.  
  61. _LVODisplay   =    _LVOShow
  62. _LVOVisible   =    _LVOShow
  63. _LVOInvisible =    _LVOHide
  64. _LVOGetParent = _LVOGetContainer
  65.  
  66. ****************************************************************************
  67. * Header used in all objects.
  68.  
  69.     STRUCTURE    Head,0
  70.     WORD    HEAD_ID       ;Object Identifier, eg ID_PICTURE
  71.     WORD    HEAD_Version  ;Version of this object.
  72.     APTR    HEAD_Class    ;Pointer to relevant system object.
  73.     APTR    HEAD_Stats    ;Private.
  74.     LABEL    HEAD_SIZEOF
  75.  
  76.     STRUCTURE    Stats,0             ;This structure is completely private.
  77.     LONG    STATS_Key           ;Resource key.
  78.     APTR    STATS_ChildPrivate  ;Available for child objects.
  79.     LONG    STATS_Flags         ;General flags.
  80.     APTR    STATS_Exclusive     ;What task owns the Exclusive.
  81.     WORD    STATS_LockCount     ;A running count of active locks.
  82.     WORD    STATS_not00         ;
  83.     LONG    STATS_MemFlags      ;Recommended memory allocation flags.
  84.  
  85. ST_SHARED      = $00000001          ;The object is being openly shared.
  86. ST_EXCLUSIVE   = $00000002          ;If object is exclusive to a process.
  87. ST_PUBLIC      = $00000004          ;If GET_PUBLIC was set on Get().
  88. ST_NOTRACKING  = $00000008          ;Do not track resources on this object.
  89. ST_INITIALISED = $00000010          ;This is set by Init().
  90.  
  91. ****************************************************************************
  92. * RawData object.
  93.  
  94. VER_RAWDATA  = 1
  95. TAGS_RAWDATA = ((ID_SPCTAGS<<16)|ID_RAWDATA)
  96.  
  97.    STRUCTURE    RD,HEAD_SIZEOF   ;Standard structure header.
  98.     LONG    RD_Size          ;Size of the data in bytes.
  99.     APTR    RD_Data          ;Pointer to the data.
  100.     BYTE    RD_AFlags        ;Private.
  101.     BYTE    RD_Pad           ;Private.
  102.     LABEL    RD_SIZEOF
  103.  
  104. ****************************************************************************
  105. * List object.
  106.  
  107. VER_ITEMLIST  = 1
  108. TAGS_ITEMLIST = ((ID_SPCTAGS<<16)|ID_ITEMLIST)
  109.  
  110.    STRUCTURE    LST,HEAD_SIZEOF  ;Standard structure header.
  111.     LONG    LST_Array        ;Pointer to the list's array.
  112.     APTR    LST_MaxSize      ;Maximum amount of objects that we can hold.
  113.  
  114. ****************************************************************************
  115. * This macro will allow you to run a DPK program directly (ie no StartDPK),
  116. * and still retain compatibility on other platforms.  It will also set up
  117. * the self-destruct mechanism so that hitting left-amiga and delete will
  118. * destroy your task and leave the system 100% intact with all resources.
  119. *
  120. * Usage: STARTDPK
  121.  
  122.    STRUCTURE    dp1,0
  123.     LONG    DPK_ID    ;ID Header.
  124.     WORD    DPK_Version    ;Version number of this program table.
  125.     WORD    DPK_DPKType    ;Type of jump table from DPK.
  126.     LONG    DPK_Start    ;Start of program.
  127.     APTR    DPK_Name    ;Name of the program.
  128.     APTR    DPK_Author    ;Who wrote the program.
  129.     APTR    DPK_Date    ;Date of compilation.
  130.     APTR    DPK_Copyright    ;Copyright details.
  131.     APTR    DPK_Short    ;Short description of program.
  132.     WORD    DPK_MinVersion    ;Minimum required DPKernel version.
  133.     WORD    DPK_MinRevision    ;Minimum required DPKernel revision.
  134.  
  135. STARTDPK MACRO
  136.     bra.s    StartAmigaDOS    ;Jump if running from AmigaDOS.
  137.  
  138.     dc.l    "PRGM"    ;ID Header.
  139.     dc.w    1    ;Version number of this program table.
  140.     dc.w    JMP_LVO    ;Type of jump table from DPK.
  141.     dc.l    StartDPKernel    ;Start of program.
  142.     dc.l    ProgName    ;Name of the program.
  143.     dc.l    ProgAuthor    ;Who wrote the program.
  144.     dc.l    ProgDate    ;Date of compilation.
  145.     dc.l    ProgCopyright    ;Copyright details.
  146.     dc.l    ProgShort    ;Short description of program.
  147.     dc.w    DPKVersion    ;Minimum required DPKernel version.
  148.     dc.w    DPKRevision    ;Minimum required DPKernel revision.
  149.  
  150. StartAmigaDOS:
  151.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save all registers.
  152. .Check    move.l    ($4).w,a6
  153.     sub.l    a1,a1
  154.     jsr    -294(a6)    ;>> = FindTask
  155.     move.l    d0,a4
  156.     tst.l    172(a4)    ;a4 = pr_CLI
  157.     bne.s    .DOS
  158.  
  159. .WBench    lea    92(a4),a0    ;a0 = pr_MsgPort
  160.     jsr    -384(a6)    ;>> = WaitPort()
  161.  
  162.     lea    92(a4),a0    ;a0 = pr_MsgPort
  163.     jsr    -372(a6)    ;>> = GetMsg()
  164.     move.l    d0,ReturnMsg    ;ma = Store message.
  165.  
  166. .DOS    move.l    ($4).w,a6    ;a6 = ExecBase
  167.     lea    DPKName(pc),a1    ;a1 = Library name.
  168.     moveq    #DPKVersion,d0    ;d0 = Version of these includes.
  169.     jsr    -552(a6)    ;>> = OpenLibrary()
  170.     lea    DPKBase(pc),a4
  171.     move.l    d0,(a4)    ;ma = Save base.
  172.     beq    ProgEnd    ;>> = Error, exit.
  173.     move.w    #1,DOS    ;ma = Started from DOS.
  174.  
  175.     move.l    d0,a6    ;a6 = DPKBase.
  176.     lea    ProgExit(pc),a0    ;a0 = Pointer to SelfDestruct() cleanup.
  177.     move.l    a7,a1    ;a1 = Stack pointer.
  178.     CALL    InitDestruct    ;>> = Initialise the call.
  179.     bra.s    Launch
  180.  
  181. StartDPKernel:
  182.     MOVEM.L    D0-D7/A0-A6,-(SP)    ;SP = Save all registers.
  183.     cmp.w    #ID_TASK,(a0)
  184.     bne    ProgEnd
  185.     lea    DPKBase(pc),a4
  186.     move.l    GT_DPKBase(a0),(a4)
  187.     lea    GVBase(pc),a4
  188.     move.l    GT_DPKBase(a0),(a4)
  189.  
  190. Launch:    move.l    DPKBase(pc),a6
  191.     moveq    #MOD_SCREENS,d0
  192.     sub.l    a0,a0
  193.     CALL    OpenModule
  194.     lea    SCRModule(pc),a4
  195.     move.l    d0,(a4)
  196.     beq.s    ProgExit
  197.     move.l    d0,a5
  198.     lea    SCRBase(pc),a4
  199.     move.l    MOD_ModBase(a5),(a4)
  200.  
  201.     moveq    #MOD_BLITTER,d0
  202.     sub.l    a0,a0
  203.     CALL    OpenModule
  204.     lea    BLTModule(pc),a4
  205.     move.l    d0,(a4)
  206.     beq.s    ProgExit
  207.     move.l    d0,a5
  208.     lea    BLTBase(pc),a4
  209.     move.l    MOD_ModBase(a5),(a4)
  210.  
  211.     moveq    #MOD_SOUND,d0
  212.     sub.l    a0,a0
  213.     CALL    OpenModule
  214.     lea    SNDModule(pc),a4
  215.     move.l    d0,(a4)
  216.     beq.s    ProgExit
  217.     move.l    d0,a5
  218.     lea    SNDBase(pc),a4
  219.     move.l    MOD_ModBase(a5),(a4)
  220.  
  221.     bsr    Start\@    ;>> = Start the program.
  222.     tst.l    d0    ;d0 = Check for error.
  223.     beq.s    ProgExit    ;>> = No errors, exit.
  224.     move.l    DPKBase(pc),a6
  225.     CALL    ErrCode    ;>> = Send the error code.
  226.  
  227. ProgExit:
  228.     move.l    DPKBase(pc),a6    ;a6 = DPKBase
  229.     move.l    SCRModule(pc),a0
  230.     CALL    Free
  231.     move.l    BLTModule(pc),a0
  232.     CALL    Free
  233.     move.l    SNDModule(pc),a0
  234.     CALL    Free
  235.  
  236.     move.w    DOS(pc),d0
  237.     beq.s    ProgEnd    ;>> = We started from the StartDPK CLI.
  238.     CALL    CloseDPK    ;>> = Close the kernel.
  239.  
  240.     move.l    ReturnMsg(pc),d0
  241.     beq.s    ProgEnd
  242.     move.l    ($4).w,a6
  243.     jsr    -378(a6)
  244.  
  245. ProgEnd    MOVEM.L    (SP)+,D0-D7/A0-A6    ;SP = Return registers.
  246.     moveq    #ERR_OK,d0    ;d0 = No errors.
  247.     rts
  248.  
  249. DOS:        dc.w  0
  250. SNDBase:    dc.l  0
  251. BLTBase:    dc.l  0
  252. SCRBase:    dc.l  0
  253. SNDModule:    dc.l  0
  254. BLTModule:    dc.l  0
  255. SCRModule:    dc.l  0
  256. ReturnMsg:    dc.l  0
  257. DPKBase:    dc.l  0    ;DPKBase.
  258. GVBase:        dc.l  0     ;Global variable base.
  259. Args:        dc.l  0    ;Pointer to argument string.
  260.  
  261. DPKName:    dc.b  "GMS:libs/dpkernel.library",0
  262.         even
  263. Start\@
  264.     ENDM
  265.  
  266. ******************************************************************************
  267. * This macro provides an easy way of sending a message to IceBreaker.
  268. * The DPKBase must be in register a6.
  269. *
  270. * Example:
  271. *
  272. *    MESSAGE    "Hello World."
  273.  
  274. MESSAGE    MACRO
  275.     MOVEM.L    A5/D7,-(SP)
  276.     moveq    #DBG_Message,d7
  277.     lea    .text\@(pc),a5
  278.     CALL    DebugMessage
  279.     bra.s    .cont\@
  280. .text\@    dc.b    \1,0
  281.     even
  282. .cont\@    MOVEM.L    (SP)+,A5/D7
  283.     ENDM
  284.  
  285. *****************************************************************************
  286. * Universal errorcodes returned by certain functions.  These are further
  287. * explained in the documentation.
  288.  
  289.  STRUCTURE Errors,0
  290.    BYTE  ERR_OK           ;Function went OK.
  291.    BYTE  ERR_NOMEM        ;Not enough memory available.
  292.    BYTE  ERR_NOPTR        ;A required address pointer is not present.
  293.    BYTE  ERR_INUSE        ;Previous allocations have not been freed.
  294.    BYTE  ERR_STRUCT       ;Structure version not supported/not found.
  295.    BYTE  ERR_FAILED       ;General/Miscellaneous failure.
  296.    BYTE  ERR_FILE         ;General file error, eg file not found, disk full etc.
  297.    BYTE  ERR_BADDATA      ;There is an error in the given data.
  298.    BYTE  ERR_SEARCH       ;An internal search was performed and it failed.
  299.    BYTE  ERR_SCRTYPE      ;Screen Type not recognised.
  300.    BYTE  ERR_MODULE       ;Trouble with initialising/using a system module.
  301.    BYTE  ERR_RASTCOMMAND  ;Invalid raster command detected.
  302.    BYTE  ERR_RASTERLIST   ;Complete rasterlist failure.
  303.    BYTE  ERR_NORASTER     ;Expected rasterlist is missing from GS_Rasterlist.
  304.    BYTE  ERR_DISKFULL     ;Disk full error.
  305.    BYTE  ERR_FILEMISSING  ;File not found.
  306.    BYTE  ERR_WRONGVER     ;Wrong version or version not supported.
  307.    BYTE  ERR_MONITOR      ;Monitor driver not found or cannot be used.
  308.    BYTE  ERR_UNPACK       ;Problem with unpacking of data.
  309.    BYTE  ERR_ARGS         ;Invalid arguments passed to function.
  310.    BYTE  ERR_NODATA       ;No data is available for use.
  311.    BYTE  ERR_READ         ;Error reading data from file.
  312.    BYTE  ERR_WRITE        ;Error writing data to file.
  313.    BYTE  ERR_LOCK         ;Could not obtain lock on object.
  314.    BYTE  ERR_EXAMINE      ;Could not examine the directory or file.
  315.    BYTE  ERR_LOSTCLASS    ;This object has lost its class reference.
  316.    BYTE  ERR_NOACTION     ;This object does not support the required action.
  317.    BYTE  ERR_NOSUPPORT    ;Object does not support the given data.
  318.    BYTE  ERR_MEMORY       ;General memory error.
  319.    BYTE  ERR_TIMEOUT      ;Function timed-out before successful completion.
  320.    BYTE  ERR_NOSTATS      ;This object has lost its stats structure.
  321.    BYTE  ERR_GET          ;Error in Get()ing an object.
  322.    BYTE  ERR_INIT         ;Error in Init()ialising an object.
  323.    BYTE  ERR_NOPERMISSION ;Used in cases of security violation.
  324.    LABEL ERR_END          ;Private code (used by IceBreaker).
  325.  
  326. ERR_SUCCESS   = ERR_OK
  327. ERR_DATA      = ERR_BADDATA
  328. ERR_LOSTSTATS = ERR_NOSTATS
  329. ERR_NOCLASS   = ERR_LOSTCLASS
  330. ERR_SECURITY  = ERR_NOPERMISSION
  331.  
  332. *****************************************************************************
  333. * Memory types used by AllocMemBlock().  This is almost identical to the
  334. * exec definition but CHIP is renamed to VIDEO (displayable memory) and
  335. * there is an addition of BLIT and SOUND specific memory.  CLEARed memory is
  336. * redundant (all GMS memory is cleared on allocation), REVERSE and NO_EXPUNGE
  337. * are also no longer needed (NB: GMS uses exec's reverse flag to reduce
  338. * fragmentation).
  339.  
  340. MEM_DATA      = $00000000   ;Default.
  341. MEM_PUBLIC    = $00000001   ;Memory can be shared between tasks.
  342. MEM_VIDEO     = $00000002   ;Suitable for the video display and blitting.
  343. MEM_BLIT      = $00000004   ;For blitting only.
  344. MEM_SOUND     = $00000008   ;Sound/Audio memory for playback of sounds.
  345. MEM_CODE      = $00000010   ;For executing code and storing data.
  346. MEM_PRIVATE   = $00000020   ;Force private memory.
  347. MEM_NOCLEAR   = $00000040   ;Do not clear the memory.
  348. MEM_RESOURCED = $00000080   ;This memory is going to be resourced.
  349. MEM_UNTRACKED = $80000000   ;Do not track the memory.
  350.  
  351. MPUBLIC       = MEM_PUBLIC  ;Synonym.
  352. MPRIVATE      = MEM_PRIVATE ;Synonym.
  353.  
  354.     IFND    SYSTEM_MODULES_I
  355.     include    'system/modules.i'
  356.     ENDC
  357.  
  358.     IFND    GRAPHICS_BLITTER_I
  359.     include    'graphics/blitter.i'
  360.     ENDC
  361.  
  362.     IFND    GRAPHICS_SCREENS_I
  363.     include    'graphics/screens.i'
  364.     ENDC
  365.  
  366.     IFND    GRAPHICS_PICTURES_I
  367.     include 'graphics/pictures.i'
  368.     ENDC
  369.  
  370.     IFND    SYSTEM_MISC_I
  371.     include 'system/misc.i'
  372.     ENDC
  373.  
  374.     IFND    SYSTEM_TASKS_I
  375.     include 'system/tasks.i'
  376.     ENDC
  377.  
  378.     IFND    SOUND_SOUND_I
  379.     include 'sound/sound.i'
  380.     ENDC
  381.  
  382.     IFND    INPUT_JOYPORTS_I
  383.     include 'input/joyports.i'
  384.     ENDC
  385.  
  386.     IFND    INPUT_KEYBOARD_I
  387.     include 'input/keyboard.i'
  388.     ENDC
  389.  
  390.     IFND    FILES_FILES_I
  391.     include 'files/files.i'
  392.     ENDC
  393.  
  394.   ENDC    ;DPKERNEL_I
  395.